package de.baumann.browser.js;

import android.webkit.JavascriptInterface;

import com.google.gson.Gson;
import com.orhanobut.logger.Logger;

import de.baumann.browser.api.net.vo.PayParam;

public class PayJs {

    private PaySuccessCallBack paySuccessCallBack;
    private PayParam payParam;

    public PayJs(PayParam payParam,PaySuccessCallBack paySuccessCallBack) {
        this(payParam);
        this.paySuccessCallBack = paySuccessCallBack;
    }

    public PayJs(PayParam payParam) {
        this.payParam = payParam;
    }

    public PayJs(PaySuccessCallBack paySuccessCallBack){
        this.paySuccessCallBack = paySuccessCallBack;
    }

    @JavascriptInterface
    public String getPayParam() {
        Logger.d(payParam);
        Gson gson = new Gson();
        return gson.toJson(payParam);
    }

    @JavascriptInterface
    public void paySuccess() {
        paySuccessCallBack.onPaySuccess();
    }

    public interface PaySuccessCallBack{
        void onPaySuccess();
    }
}
